<?php
$this->pageTitle = 'View Products';
$this->breadcrumbs=array(
	'Products'=>array('index'),
	$model->name,
);
?>
<div class="heading">
    <h1><img src="<?php echo Util::themeUrl() ?>/images/default.png" />View Products #<?php echo $model->id; ?></h1>
    <div class="controls">
        <?php
        if (isset($_GET['ajax'])) {
            echo CHtml::button('Update', array('class' => 'controls', 'onclick' => "location.href='" . $this->createUrl('update', array('id' => $model->id, 'ajax' => true)) . "'"));
            echo CHtml::ajaxButton('Delete', array('delete', 'ajax' => true), array(
                'type' => 'post',
                'data' => "chk[]={$model->id}",
                'success' => 'function(data){$(".controls").hide(); $(".content").html(data);}'
            ), array('class' => 'controls'));
        } else {
            echo CHtml::link('Manage', array('index'), array('class' => 'controls'));
            echo CHtml::link('Update', array('update', 'id' => $model->id), array('class' => 'controls'));
            echo CHtml::link('Delete', array('delete'), array(
                'class' => 'controls',
                'submit' => array('delete'),
                'confirm'=>'Are you sure you want to delete this item?',
                'params' => array('chk[]' => $model->id),
                'ajax' => array('type' => 'post')
            ));
        }
     ?>
    </div>
</div>

<div class="content">
<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'id',
		'category_id' => array(
			'name'	=> 'category_id',
			'value' => $model->category->name
		),
//		'code',
		'name',
		'price' => array(
					'value' => number_format($model->price, 0, " ", " "),
                    'name' => 'price',
		),
		'short_descript' => array(
                    'name' => 'short_descript',
                    'type' => 'raw',
                ),
		'description' => array(
                    'name' => 'description',
                    'type' => 'raw',
                ),
		'promote' => array(
                    'name' => 'promote',
                    'type' => 'raw',
                    'value' => ($model->promote == 1)? "Yes" : "No",
                ),
		'created',
		'updated',
        'thumb' => array(
					'name' => 	'thumb',
					'type' => 	'raw',
		        	'value'=>	CHtml::image(Util::getImageExist("thumb", $model->thumb), "thumb",  array("width" => "70", "height" => "70", "border" => "0")),
					'htmlOptions' => array(
		                'style' => 'width:80px;text-align:center'
		            ),
		),
		'image'=> array(
					'name' => 	'image',
					'type' => 	'raw',
		        	'value'=>	CHtml::image(Util::getImageExist("card", $model->image), "image",  array("width" => "380", "height" => "205", "border" => "0")),
					'htmlOptions' => array(
		                'style' => 'width:80px;text-align:center'
		            ),
		),
	),
)); ?>
</div>
